# -*- coding: utf-8 -*-

'''eof
name:申请人与烟草登记负责人不一致
code:MG_Applicant_Not_SmokeRegPerson
tableName:
columnName:
groups:烟商基本资质
dependencies:BATCH_INDEX_MONTH
type:常用指标
datasourceType:在线指标
description:
eof'''


import sys
import pandas as pd
import datetime

reload(sys)
sys.setdefaultencoding('utf-8')

before_index_code = "Applicant_Not_SmokeRegPerson"


def format_data(base_name):
    try:
        return base_name if isinstance(base_name, list) and len(base_name) > 0 else [{}]
    except:
        return [{}]


def MG_Applicant_Not_SmokeRegPerson():
    null_type_list = ['', None, 'null', 'Null', 'NULL', '/', ' ']
    try:
        score_list = format_data(BATCH_INDEX_MONTH)

        if score_list == [{}]:
            return u'缺失值'
        else:
            if len(score_list) >= 1:
                for i in score_list:
                    if i.get("index_code") not in null_type_list and i.get("value") not in null_type_list\
                            and i.get("index_code") == before_index_code:
                        return i.get("value")
                return u'缺失值'
            else:
                return u'缺失值'
    except:
        return u'缺失值'


result = MG_Applicant_Not_SmokeRegPerson()